<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在vue中使用animate.css库</title>
    <script src="./js/vue.js"></script>
    <link rel="stylesheet" href="./css/animate.css">
    <style>
        @keyframes bounce{
            0% { 
                transform: scale(0);
            }
            50% {
                transform: scale(1.5);
            }

            100% {
                transform: scale(1);
            }

        }
        .fade-enter-active{
            transform-origin: left center;
            animation: bounce 1s;
        }
        .fade-leave-active{
            transform-origin: left center;
            animation: bounce 1s reverse;
        }
        /* 自定义class */
        .enter{
            transform-origin: left center;
            animation: bounce 2s;
        }
        .leave{
            transform-origin: left center;
            animation: bounce 2s;
        }
    </style>
</head>
<body>
    <div id="root">
        <!-- 使用keyframe形式 -->
        <transition name="fade">
            <div v-if="show">hello vue and keyframe!</div>
        </transition>

        <!-- 使用自定义class -->
        <transition enter-active-class="enter" leave-active-class="leave">
            <div v-if="show">hello vue and 自定义class</div>
        </transition>
        <!-- <button @click="handleBtnClick">切换</button> -->
        <br>

        <!-- 使用animate.css库 -->
        <transition enter-active-class="animated bounce" leave-active-class="animated bounceOut">
            <div v-if="show">hello vue and animate.css</div>
        </transition>
        <button @click="handleBtnClick">切换</button>
    </div>
    <script>
        var vm = new Vue({
            el: "#root",
            data: {
                show: true,
            },
            methods: {
                handleBtnClick: function(){
                    this.show = !this.show;
                }
            }
        });
    </script>
</body>
</html>